package org.fsm.boot;

import lombok.extern.slf4j.Slf4j;
import org.fsm.entity.CreditEntity;
import org.fsm.constants.CreditStatusEnum;
import org.fsm.constants.CreditStatusEventEnum;

/**
 * @ClassName: CreditServiceDemo
 * @Description:
 * @Author: Donaldhan
 * @Date: 2018-05-15 18:00
 */
@Slf4j
public class CreditServiceDemo {
    /**
     * 贷前调查
     * @param creditEntity
     * @return
     */
      public CreditEntity checkCredit(CreditEntity creditEntity){
          //当前状态可以转化为贷前调查通过状态
          if(CreditStatusEventEnum.CHECK_PASS.canFire(creditEntity.getStatus())){
              // 进行贷前调查相关操作
              //贷前调查通过,更新信贷审核流程状态
              creditEntity.setStatus(CreditStatusEnum.CHECK.getCode());
              //updateCreditStatus(creditEntity);
          }
          else{
              log.error("当前信贷状态：{}，不可转化为贷前调查通过状态",creditEntity.getUserName());
          }
          return creditEntity;
       }

    /**
     * 贷款审查
     * @param creditEntity
     * @return
     */
    public CreditEntity auditCredit(CreditEntity creditEntity){
        //当前状态可以转化为贷款审查通过状态
        if(CreditStatusEventEnum.AUDIT_PASS.canFire(creditEntity.getStatus())){
            // 进行贷款审查通过相关操作
            //贷款审查通过通过,更新信贷审核流程状态
            creditEntity.setStatus(CreditStatusEnum.AUDIT.getCode());
            //updateCreditStatus(creditEntity);
        }
        else{
            log.error("当前信贷状态：{}，不可转化为贷款审查通过通过状态",creditEntity.getUserName());
        }
        return creditEntity;
    }
}
